package net.esj.basic.utils.writer;

import java.io.Serializable;
import java.lang.annotation.Annotation;

public class SignImpl implements Signed, Serializable {

	private final String[] groups;
	
	public SignImpl(String... value) {
		if (value != null) {
			this.groups = value;
		} else {
			this.groups = new String[]{""};
		}
	}

	public String[] groups() {
		return this.groups;
	}

	public int hashCode() {
		// This is specified in java.lang.Annotation.
		return (127 * "groups".hashCode()) ^ groups.hashCode();
	}

	public boolean equals(Object o) {
		if (!(o instanceof Signed)) {
			return false;
		}

		Signed other = (Signed) o;
		return groups.equals(other.groups());
	}

	public String toString() {
		return "@" + Signed.class.getName() + "(groups=" + groups + ")";
	}

	public Class<? extends Annotation> annotationType() {
		return Signed.class;
	}

	private static final long serialVersionUID = 0;

}
